#ifndef __CONTROLACC_H__
#define __CONTROLACC_H__

#include "plat/nonecopyable.h"

class ControlAcc : public NoneCopyable
{
public:
    enum class ControlState
    {
        Idle = 0,
        Acc,
        ConstSpeed,
        Dec
    };

public:
    explicit ControlAcc();
    virtual ~ControlAcc();

public:
    void Config(int v0, int vMax, int toMaxUs);
    void ConfigConstSpeed(int vMax);
    void StartAcc();
    void StartDec();
    void Reset();
    /// @brief 
    /// @param us 增量us 
    /// @return 
    int Update(int us);

    inline bool IsEmptyConfig(){return m_emptyConfig;}
    inline int GetCurrentValue(){return m_currentV;}

public:
    int m_v0 = 0;
    int m_vMax = 0;
    int m_toMaxUs = 0;
    bool m_isConstSpeed = false;
    bool m_emptyConfig = true;

    ControlState m_state = ControlState::Idle;
    float m_speed = 0; //v/us
    int m_totalUs = 0; //加减速的时间积分
    int m_currentV = 0;
};

#endif // __CONTROLACC_H__
